////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2012 Kentaro Sekimoto  All rights reserved.
////////////////////////////////////////////////////////////////////////////

#include <tinyhal.h>
#include "..\..\..\..\..\DeviceCode\Targets\Native\FM3\DeviceCode\FM3.h"

//--//

#ifdef MB9BF506N

// CLK  P3F
// DI   P3C
// CS   P3D
// RS   P10
volatile unsigned int* spisw_rs = &(bFM3_GPIO_PDOR1_P0);
volatile unsigned int* spisw_di = &(bFM3_GPIO_PDOR3_PC);
volatile unsigned int* spisw_ck = &(bFM3_GPIO_PDOR3_PF);
volatile unsigned int* spisw_cs = &(bFM3_GPIO_PDOR3_PD);

void SPISW_GPIO_Initialize(void)
{
    bFM3_GPIO_PFR1_P0 = 0;
    bFM3_GPIO_PFR3_PC = 0;
    bFM3_GPIO_PFR3_PF = 0;
    bFM3_GPIO_PFR3_PD = 0;

    bFM3_GPIO_DDR1_P0 = 1;
    bFM3_GPIO_DDR3_PC = 1;
    bFM3_GPIO_DDR3_PF = 1;
    bFM3_GPIO_DDR3_PD = 1;
}

#else

// CLK  P3F
// DI   P3C
// CS   P3D
// RS   P10
volatile unsigned int* spisw_rs = &(bFM3_GPIO_PDOR1_P0);
volatile unsigned int* spisw_di = &(bFM3_GPIO_PDOR3_PC);
volatile unsigned int* spisw_ck = &(bFM3_GPIO_PDOR3_PF);
volatile unsigned int* spisw_cs = &(bFM3_GPIO_PDOR3_PD);

void SPISW_GPIO_Initialize(void)
{
    bFM3_GPIO_PFR1_P0 = 0;
    bFM3_GPIO_PFR3_PC = 0;
    bFM3_GPIO_PFR3_PF = 0;
    bFM3_GPIO_PFR3_PD = 0;

    bFM3_GPIO_DDR1_P0 = 1;
    bFM3_GPIO_DDR3_PC = 1;
    bFM3_GPIO_DDR3_PF = 1;
    bFM3_GPIO_DDR3_PD = 1;
}

#endif
